{% extends 'base.html' %}

{% load signup_extras %}

{% block title %}Moderate local issues{% endblock %}

{% block extra-head %}
<link rel="stylesheet" type="text/css"  media="screen" href="{{ MEDIA_URL }}issues/issues.css" />
{% endblock %}

{% block js %}
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
 <script type="text/javascript">
    $(document).ready(function () {        
        $('#id_guide').hide();
    });
 </script>
{% endblock %}

{% block content %}

<div class="span-6 task">
{% if submitted %}
 <div style="padding:0.5em;border:1px solid #EEE;margin-top:1em;margin-bottom:1em;">
    <h3 style="margin-top:0">Thank you for moderating an issue!</h3>
    Please carry on :)
 </div>
{% else %}
 <h3>
  Moderate local issues
 </h3>
{% endif %}

{{ form.errors }}

{% if form %}
    <form action="" method="post" id="moderate_issue" >
        <input type="hidden" name="id" value="{{ issue.id }}"/>
        <div class="fieldWrapper">
            {{ form.reference_url.errors }}
            <h4>1. Check the source link (if there is one)</h4>
            {{ form.reference_url }}
            <br/><a href="{{ issue.reference_url }}" target="_blank">Open source link (in new window)</a>
            <p>If you can find a more detailed, or less partisan, article about the issue,
            change the link to that.</p>
        </div>
        <div class="fieldWrapper">
            {{ form.question.errors }}
            <h4>2. Tidy statement of the local issue</h4>
            {{ form.question }}
        </div>
        <ul class="moderate_buttons">
            <li><input type="submit" value="Approve" id="id_approve" name="Approve" /></li>
            <li><input type="submit" value="Hide (not local)" id="id_hide" name="Hide-notlocal" /></li>
            <li><input type="submit" value="Hide (too general, can't make yes/no)" id="id_hide" name="Hide-toogeneral" /></li>
            <li><input type="submit" value="Hide (can't formulate a policy)" id="id_hide" name="Hide-nopolicy" /></li>
            <li><input type="submit" value="Hide (other)" id="id_hide" name="Hide-other" /></li>
            <li><a href="?">Skip this issue</a></li>
        </ul>
        <div class="clear"></div>
    </form>
{% endif %}
    <h3>Guidelines for tidying local issue statements</h3>
    <p>Rewrite the statement so that it is:</p>
        <ul>
            <li>A local issue (we'll cover national ones separately).</li>
            <li>Possible for somebody to record agreement/disagreement/no
            opinion.</li>
            <li>If forward looking, the statement should argue for a
            specific change to current or planned policy (e.g. "increase funding to provide a service",
            not simply "provide a service")
            </li>
            <li>If backward looking, the statement should not aportion blame, but simply describe
               an alternative decision.</li>
            <li>A proper sentence, with a leading capital and 
            a full stop.</li>
            <li>If the issue mentions a public body, check it is the right one (e.g. has the powers
            ascribed to it).</li>
        </ul>

    <h3>Top recent players</h3>
    <table>
    {% for user, count in league_table_this_week %}
        <tr>
            <td> {{ forloop.counter }} <td>
            <td> {{ user.display_name }} </td>
            <td> {{ count }} issue{{ count|pluralize }} </td>
        </tr>
    {% endfor %}
    </table>

    <h3>All time best players</h3>
    <table>
    {% for user, count in league_table_all_time %}
        <tr>
            <td> {{ forloop.counter }} <td>
            <td> {{ user.display_name }} </td>
            <td> {{ count }} issue{{ count|pluralize }} </td>
        </tr>
    {% endfor %}
    </table>

</div>

<div class="span-2 last">
    <p style="text-align: center">
        <img width="200" height="125" src="http://chart.apis.google.com/chart?chs=200x125&cht=gom&chd=t:{{ percentage }}" alt="{{ percentage }} of issues have been moderated">
        <br>{{ missing }} issue{{ missing|pluralize }} left to moderate / {{ total }} total
    </p>

     <h3>Issues in {{ constituency.name }}</h3>
    {% if issues %}
     <ul>
     {% for issue in issues %}
      <li>{{ issue.question }}{% if issue.reference_url %} (<a href="{{ issue.reference_url }}" target="_blank">source</a>){% endif %}</li>
     {% endfor %}
     </ul>
    {% else %}
    <ul>
        <li>Nobody has added any issues here yet</li>
    </ul>
    {% endif %}

    {% if hidden_issues %}
     <h3>Hidden issues</h3>
     <p><em>These have been rejected by other moderators.</em>
     <ul>
     {% for issue in hidden_issues %}
      <li>{{ issue.question }}{% if issue.reference_url %} (<a href="{{ issue.reference_url }}" target="_blank">source</a>){% endif %}</li>
     {% endfor %}
     </ul>
    {% endif %}
</div>

{% endblock %}
